xenconsole: Allow non-interactive use
authorMartin Lucina <martin@lucina.net>
Fri, 24 Jul 2015 11:30:48 +0000 (13:30 +0200)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 24 Jul 2015 11:41:24 +0000 (12:41 +0100)
commit9072240954fc8a7c74ae04d2eb51c98bc0cb3356
treea4711abda28d48227e411d09f7445c2b907e9d7d
parent78222eb476e24833880a94e8cbd193e797abbe18
xenconsole: Allow non-interactive use

If xenconsole is run with stdin closed or redirected to /dev/null,
console_loop() will return immediately due to failure to read from
STDIN_FILENO. This patch tests if stdin and stdout are both connected to
a TTY and, if not, xenconsole will not attempt to read from stdin or
modify stdout terminal attributes.

Existing behaviour when xenconsole is run from a terminal does not
change.

This allows for non-interactive use, eg. running "xl create -c" under
systemd or piping the output of "xl console" to another command.

Signed-off-by: Martin Lucina <martin@lucina.net>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/console/client/main.c